package com.zhl.byte_stream4;

import java.io.*;

public class CopyTest {
    public static void main(String[] args) throws Exception {
        //1。复制照片
        InputStream is = new FileInputStream("src/Copy1.png");

        //2.创建一个字节输出流管道
        OutputStream os = new FileOutputStream("src/com/zhl/byte_stream4/photo_copy.png");

        //3.创建字节数组，复负责转移字节数据
        byte[] buffer = new byte[1024];   //1kb

        //4.从字节输入流中读取数据，写出去到字节输出流中，读多少写多少
        int len;
        while ((len = is.read(buffer))!= -1) {
            os.write(buffer, 0, len);
        }

        //5.关闭流
        is.close();
        os.close();
    }
}
